import React from "react";
import { createStore } from "redux";
import {
  Provider,
  createStoreHook,
  createDispatchHook,
  createSelectorHook,
} from "react-redux";
export const MyContext = React.createContext({ abc: 1 }); // 这里初始化的值有什么用？

export const useStore = createStoreHook(MyContext);
export const useDispatch = createDispatchHook(MyContext);
export const useSelector = createSelectorHook(MyContext);

function rootReducer(state = { count: 0 }, action) {
  const count = state.count;

  switch (action.type) {
    case "increase":
      return { count: count + 1 };
    default:
      return state;
  }
}

const myStore = createStore(rootReducer, { count: 1, from: "counter.global" });

export default myStore;
